// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;

LL bin(LL a, LL b, LL p) {
	LL res = 1;
	for (a%=p; b; b>>=1, a=a*a%p)
		if (b & 1)
			res = res * a % p;
	return res;
}

LL n;

LL solve1(LL n) {
	LL cur = 1;
	while (n >= cur) {
		n -= cur;
		cur <<= 2;
	}
	return cur + n;
}

LL solve2(LL n) {
	LL cur = 1;
	while (n >= cur) {
		n -= cur;
		cur <<= 2;
	}
	LL base = cur * 2;
	LL addi = 0, y = cur/4;

	const int f[] = {0, 2, 3, 1};
	// dbg(n, cur);
	while (n && y) {
		// dbg(n, y, n/y);
		addi += y*f[(n/y)];
		n %= y;
		y /= 4;
	}
	return base + addi;
}

int main(int argc, char const *argv[]) {
    // code
    int t;
    scanf("%d", &t);
    for (int kk=0; kk<t; ++kk) {
    	scanf("%lld", &n);
    	--n;
    	LL n1 = solve1(n/3), n2 = solve2(n/3);
	    LL n3 = n1 ^ n2;
	    if (n % 3 == 0)
	    	// cout << n1 << endl;
	    	printf("%lld\n", n1);
	    else if (n % 3 == 1)
	    	// cout << n2 << endl;
	    	printf("%lld\n", n2);
	    else
	    	printf("%lld\n", n3);
	    	// cout << n3 << endl;
    }
    // cin >> n;
    // --n;
    // LL n1 = solve1(n/3), n2 = solve2(n/3);
    // LL n3 = n1 ^ n2;
    // if (n % 3 == 0)
    // 	cout << n1 << endl;
    // else if (n % 3 == 1)
    // 	cout << n2 << endl;
    // else
    // 	cout << n3 << endl;
    // // solve2(7);
    // dbg(solve1(33), solve2(33));
    return 0;
}